<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\domainsStop;


Class DomainsStopModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }
    
    public function findAll()
    {
        //$domainsStop = $this->em->getRepository('BillingBundle:domainsStop')->findAll();
        //return $domainsStop;
        $query = $this->em->createQuery('SELECT dS FROM BillingBundle:domainsStop dS order by dS.name');
        $domainsStop = $query->getResult();
        return $domainsStop;
    }
    
    public function FindByPK($domainStop_id)
    {
        $domainStop = $this->em->find('BillingBundle:domainsStop', $domainStop_id);
        return $domainStop;
    }
    
    public function findByDomainName($domain_name)
    {
        $domain = $this->em->getRepository('BillingBundle:domainsStop')->findOneBy(array('name' => $domain_name, 'is_active' => '1'));
        return $domain;
    }
    
    public function create($oEntity)
    {
        $this->em->persist($oEntity);
        $this->em->flush();
    }
    
    public function removeByPK($domainStop_id)
    {
        $domainStop = $this->em->find('BillingBundle:domainsStop', $domainStop_id);
        $this->em->remove($domainStop);
        $this->em->flush();
    }
}
?>
